package com.example.wanbaqian.adapter;

import android.content.Context;
import android.view.View;

import com.example.wanbaqian.R;
import com.example.wanbaqian.bean.RepaymentListByStageBean;
import com.example.wanbaqian.utils.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/4/13 0013.
 * 某一期的还款列表适配器
 */

public class RepaymentListByStageAdapter extends CommonAdapter<RepaymentListByStageBean> {
    public RepaymentListByStageAdapter(Context context, int layoutId, List<RepaymentListByStageBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    public void onViewHolderCreated(ViewHolder holder, View itemView) {
        super.onViewHolderCreated(holder, itemView);
        AutoUtils.autoSize(itemView);
    }

    @Override
    protected void convert(ViewHolder holder, RepaymentListByStageBean repaymentListByStageBean, int position) {
        holder.setText(R.id.item_rls_stage, "第" + repaymentListByStageBean.getCurrent_stage() + "期");
        holder.setText(R.id.item_rls_time, TimeUtils.getStrTime(repaymentListByStageBean.getRepay_end_time(), ""));
        holder.setText(R.id.item_rls_Principal, repaymentListByStageBean.getLoan_capital() + "元");
        holder.setText(R.id.item_rls_serviceCharge, repaymentListByStageBean.getLoan_interest() + "元");
        holder.setText(R.id.item_rls_overdueTime, repaymentListByStageBean.getOverdue_days() + "天");
        holder.setText(R.id.item_rls_overdueMoney, repaymentListByStageBean.getLoan_latefee() + "元");
        holder.setBackgroundRes(R.id.item_rls_Iv, repaymentListByStageBean.getRepay_status().equals("2") || repaymentListByStageBean.getRepay_status().equals("3") ? R.drawable.return_success : R.drawable.repay_background);
        holder.setVisible(R.id.item_rls_Iv, repaymentListByStageBean.getRepay_status().equals("0") ? false : true);
    }
}
